﻿use AdventureWorks2012;


declare @sql nvarchar(MAX)='
SELECT TOP (5) 
       ProductID, 
       EndDate, 
       DATENAME(MONTH, EndDate) AS MonthName, 
       DATENAME(WEEKDAY, ''2013-06-09'') AS WeekDayName 
FROM   Production.ProductCostHistory 
WHERE  EndDate IS NOT NULL; '

EXEC sp_executesql @sql ; 

SELECT column_ordinal, 
   is_nullable, 
   system_type_name 
FROM  master.sys.dm_exec_describe_ﬁrst_result_set(@sql, NULL, 0) a ;



SELECT MyData ,
ISDATE(MyData) AS IsADate
FROM (VALUES('IsThisADate'),
('2012-02-14'),
('2012-01-01T00:00:00'),
('2012-12-31T23:59:59.9999999')) dt(MyData);


SELECT 'DateFromParts' AS ConversionType,
DATEFROMPARTS(2012, 8, 15) AS [Value];
SELECT 'TimeFromParts' AS ConversionType,
TIMEFROMPARTS(18, 25, 32, 5, 1) AS [Value];
SELECT 'SmallDateTimeFromParts' AS ConversionType,
SMALLDATETIMEFROMPARTS(2012, 8, 15, 18, 25) AS [Value];
SELECT 'DateTimeFromParts' AS ConversionType,
DATETIMEFROMPARTS(2012, 8, 15, 18, 25, 32, 450) AS [Value];
SELECT 'DateTime2FromParts' AS ConversionType,
DATETIME2FROMPARTS(2012, 8, 15, 18, 25, 32, 5, 7) AS [Value];
SELECT 'DateTimeOffsetFromParts' AS ConversionType,
DATETIMEOFFSETFROMPARTS(2012, 8, 15, 18, 25, 32, 5, 4, 0, 7) AS [Value];

select 
isdate(CAST(CAST(2013  AS varchar) + '-' + CAST(6 AS varchar) + '-' + CAST(13 AS varchar) AS DATETIME))


select isdate(CAST(Getdate() AS date) as [Current Date]
select isdate(cast(getdate() as time(0))) as [Current Time] 

